<%@ page contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ page trimDirectiveWhitespaces="true"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>


<div class="widget-box">
	<div class="widget-header header-color-pink">
		<h5>
			<i class="icon-edit"></i>修改用户
		</h5>
		<div class="widget-toolbar no-border">
			<button id="back" class="btn btn-xs btn-yellow bigger" onclick="trans2('/system/user');">
				<i class="icon-arrow-left"></i> 返回
			</button>
		</div>
	</div>

	<div class="widget-body">
		<div class="widget-main">

			<form class="form-horizontal" id="addUserForm" action="/system/user_saveOrupdate" method="post" role="form">

				<div class="space-4"></div>

				<div class="form-group">
					<label class="col-sm-3 control-label no-padding-right"> 用户名 </label>

					<div class="col-sm-4">
						<input type="text" name="username" readonly="readonly" id="username" placeholder="用户名" value="${user.username}" class="col-xs-10 col-sm-12" />
					</div>
				</div>

				<div class="space-4"></div>

				<div class="form-group">
					<label class="col-sm-3 control-label no-padding-right"> 工号 </label>

					<div class="col-sm-4">
						<input type="text" name="code" id="code" placeholder="工号" value="${user.code}" class="col-xs-10 col-sm-12" />
					</div>
				</div>

				<div class="space-4"></div>

				<div class="form-group">
					<label class="col-sm-3 control-label no-padding-right"> 职位 </label>

					<div class="col-sm-4">
						<input type="text" name="comment" id="comment" placeholder="职位" value="${user.comment}" class="col-xs-10 col-sm-12" />
					</div>
				</div>

				<div class="space-4"></div>

				<div class="form-group">
					<label class="col-sm-3 control-label no-padding-right"> 姓名 </label>

					<div class="col-sm-4">
						<input type="text" name="name" id="name" placeholder="姓名" value="${user.name}" class="col-xs-10 col-sm-12" />
					</div>
				</div>

				<div class="space-4"></div>

				<div class="form-group">
					<label class="col-sm-3 control-label no-padding-right"> 电话号码 </label>

					<div class="col-sm-4">
						<input type="text" id="mobile" name="mobile" placeholder="电话号码" value="${user.mobile}" class="col-xs-10 col-sm-12" />
					</div>
				</div>

				<%-- <div class="form-group">
					<label class="col-sm-3 control-label no-padding-right"> 角色 </label>

					<div class="col-sm-9" style="line-height: 25px;">
						<!-- [{"value":"登录","code":"login"},{"value":"历史数据","code":"history"},{"value":"数据分析","code":"analysis"},{"value":"系统管理","code":"sys"}] -->
						<c:forEach var="auth" items="${auths}">
							<label> <input name="auth" class="ace ace-radio-2" <c:if test="${fn:contains(user.auth,auth.code)}">checked="checked"</c:if> value="${auth.code}" type="radio"> <span class="lbl">
									${auth.des} </span>
							</label>
								&nbsp;&nbsp;&nbsp;
							</c:forEach>
					</div>
				</div> --%>

				<div class="space-4"></div>

				<div class="clearfix form-actions">
					<div class="col-md-offset-3 col-md-9">
						<button id="save" class="btn btn-info" type="button" onclick="form_save('addUserForm','/system/user_saveOrupdate');">
							<i class="icon-ok bigger-110"></i> 保存
						</button>

						&nbsp; &nbsp; &nbsp;
						<button id="cancel" onclick="trans2('/system/user');" class="btn">
							<i class="icon-undo bigger-110"></i> 取消
						</button>
					</div>
				</div>

				<!-- <div class="hr hr-24"></div> -->
				<input id="userId" type="hidden" name="id" value="${user.id}" />
			</form>

		</div>

	</div>
</div>

<script type="text/javascript">
$('#addUserForm').validate({
	errorElement : 'div',
	errorClass : 'help-block',
	focusInvalid : false,
	rules : {
		username : {
			required : true,
		},
		comment : {
			required : true,
		},
		name : {
			required : true,
		},
		mobile : {
			required : true,
			number : true
		}
	},

	messages : {
		username : {
			required : "用户名不能为空！",
		},
		comment : {
			required : "职位不能为空！",
		},
		name : {
			required : "姓名不能为空！",
		},
		mobile : {
			required : "电话号码不能为空！",
			number : "电话号码只能输入数字！"
		}
	},

	invalidHandler : function(event, validator) { // display error alert on
													// form submit
		$('.alert-danger', $('.login-form')).show();
	},

	highlight : function(e) {
		$(e).closest('.form-group').removeClass('has-info').addClass('has-error');
	},

	success : function(e) {
		$(e).closest('.form-group').removeClass('has-error').addClass('has-info');
		$(e).remove();
	},

	errorPlacement : function(error, element) {
		if (element.is(':checkbox') || element.is(':radio')) {
			var controls = element.closest('div[class*="col-"]');
			if (controls.find(':checkbox,:radio').length > 1)
				controls.append(error);
			else
				error.insertAfter(element.nextAll('.lbl:eq(0)').eq(0));
		} else if (element.is('.select2')) {
			error.insertAfter(element.siblings('[class*="select2-container"]:eq(0)'));
		} else if (element.is('.chosen-select')) {
			error.insertAfter(element.siblings('[class*="chosen-container"]:eq(0)'));
		} else
			error.insertAfter(element.parent());
	},

	submitHandler : function(form) {
	},
	invalidHandler : function(form) {
	}
});
</script>